<?php if (!defined('insite')) die("no access"); 
//global $config;
//global $premium;
 require "opt.php";
if ($_GET["guild"])
{
 $nedd_g = validate(substr($_GET["guild"],0,10));

 $db = new Connect ($config["ctype"], $config["db_host"], $config["db_name"], $config["db_user"], $config["db_upwd"],$config["odbc_driver"],$config["debug"]); 
 $g_result = $db->fetcharray($db->query("SELECT G_Name,G_Score,G_Mark,G_Master,G_Union, number FROM guild Where G_Name='". $nedd_g."'"));
 
 $g_result["G_Mark"] = GuildLogo($g_result["G_Mark"],$g_result["G_Name"],64,$config["logotime"]);
 
 $content = new content();
 $content->set('|G_Name|', $g_result["G_Name"]);
 $content->set('|G_Mark|', $g_result["G_Mark"]);
 $content->set('|topguild_score|', topguild_score);
 $content->set('|G_Score|', $g_result["G_Score"]);
 $content->set('|lang_g_status|', lang_g_status);
 $content->set('|lang_gName|', lang_gName);
 $content->out_content("theme/".$config["theme"]."/them/search_h.them");
 
 $m_result = $db->query("SELECT Name,G_Status FROM GuildMember WHERE G_Name= '".$g_result["G_Name"]."' ORDER BY G_Status DESC, Name DESC");

 while ($gmember = $db->fetchrow($m_result))
 {
	$content->set('|guild_stat|', $guild_st[$gmember[1]]);
	$content->set('|gmname|', $gmember[0]);
	$content->out_content("theme/".$config["theme"]."/them/search_c.them");
 }
 
 $aliance="";
 if ($row4[4]!=0)
 {
  $guilds = $db->query("SELECT G_Name FROM Guild WHERE G_Union='".$row4[4]."' or number='".$row4[4]."' or G_Union='".$row4[5]."'");
  while ($g_data = $db->fetcharray($guilds))
  if($g_data["G_Name"]!=$row4[0])$aliance .= "<div><a href='#".$g_data["G_Name"]."'>".$g_data["G_Name"]."</a></div>";
 }
$content->set('|aliance|', $aliance);
$content->out_content("theme/".$config["theme"]."/them/search_f.them");				
}
elseif($_GET["caracter"])
{
	$show_ch = validate(substr($_GET["caracter"],0,10));
	$db = new Connect ($config["ctype"], $config["db_host"], $config["db_name"], $config["db_user"], $config["db_upwd"],$config["odbc_driver"],$config["debug"]); 
	

	$array = $db->fetchrow($db->query("select inventory, class , cLevel,".$config["res_colum"].",gr_res,Strength,Dexterity,Vitality,Energy,Leadership,AccountID from character where name='".$show_ch."'"));
	if (strlen($array[1])>0)
	{
	$content = new content();
	  if ($premium["on"]==1)
	  {
	  $respr = $db->fetchrow($db->query("SELECT opt_inv FROM MEMB_INFO WHERE memb___id='".$array[10]."'"));
	  $guild = $db->fetchrow($db->query("SELECT G_Name FROM GuildMember WHERE Name= '".$show_ch."'"));
	  if (strlen($guild[0])<2) $guild[0]="no guild";
	  else $guild[0]="<a href='".$config["siteaddress"]."/?p=search&guild=".$guild[0]."'>".$guild[0]."</a>";
		//center
		$content->set('|name|', $show_ch);
		$content->set('|level|', $array[2]);
		$content->set('|res|', $array[3]);
		$content->set('|grres|', $array[4]);
		$content->set('|str|', stats65($array[5]));
		$content->set('|agi|', stats65($array[6]));
		$content->set('|vit|', stats65($array[7]));
		$content->set('|ene|', stats65($array[8]));
		$content->set('|cmd|', stats65($array[9]));
		$content->set('|guild|', $guild[0]);
		$content->out_content("theme/".$config["theme"]."/them/search_ch_c.them");
		
		//footer
		$content->out_content("theme/".$config["theme"]."/them/search_ch_f.them");
	 }else echo "No character!";
	}
}
else echo "<center>error!</center>";